package javaagent.httpInvoker.http;

import javaagent.httpInvoker.ProxyHttpUrlConnection;

import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;

/**
 * @author ：zzs
 * @version : 1.0
 * @date ：Created in 2022/3/11 21:06
 * @description：
 */
public class HttpsHandler extends sun.net.www.protocol.https.Handler {
    @Override
    protected URLConnection openConnection(URL url, Proxy proxy) throws IOException {
        HttpURLConnection connection = (HttpURLConnection) super.openConnection(url, proxy);
        return new ProxyHttpUrlConnection(connection, url);
    }

    @Override
    protected URLConnection openConnection(URL url) throws IOException {
        return openConnection(url, (Proxy) null);
    }
}
